package com.woniuxy.carlife.controller;

import com.woniuxy.carlife.dto.UserAppraiseDto;
import com.woniuxy.carlife.feign.UserFeign;
import com.woniuxy.carlife.feigndto.StoreServiceDto;
import com.woniuxy.carlife.feigndto.UserCommentDto;
import com.woniuxy.carlife.feignservice.StoreFeignService;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author fx
 * @ClassName:CouponCategoryController
 * @Description: 用户关联的服务点赞控制类，不对前端展示
 * @date 2021/4/14 19:36
 **/
@RestController
@RequestMapping("/userServiceLike")
@Api(tags = "自己测试用的接口")
public class UserServiceLikeController {

    @Resource
    private StoreFeignService service;

    @Resource
    private UserFeign userFeign;

    @Resource
    private StoreFeignService feignService;

    /**
     * 功能描述〈根据门店id统计该门店下所有服务的点赞量、评论量和评分〉
     * @author:fx
     * @param: @param null:
     * @return:
     * @Date 2021/4/16 9:29
     * @throws
     */
    @GetMapping("servicelike")
    public StoreServiceDto findAllServiceLikeAndAppriseNumByStoreId(Integer storeId){
        System.out.println("查询服务点赞数传的门店id是"+storeId);
        StoreServiceDto storeServiceByStoreId =
                service.findStoreServiceByStoreId(storeId);
        return storeServiceByStoreId;
    }

    /**
     * 功能描述〈查询用户账号和头像〉
     * @author:fx
     * @param: @param null:
     * @return:
     * @Date 2021/4/16 11:20
     * @throws
     */
    @GetMapping("userhead")
    public UserAppraiseDto findUserPhoneAndHead(){
        UserCommentDto f = userFeign.userConmmentByUserId();
        System.out.println(userFeign.userConmmentByUserId().getClass());
        System.out.println(userFeign.userConmmentByUserId());
        UserAppraiseDto u = new UserAppraiseDto();
            //昵称
            u.setPhone(f.getUserInfoNickname());
            //头像
            u.setHeadImage(f.getUserInfoImage());
        return u;
    }



    /**
     * 功能描述〈测试〉
     * @author:fx
     * @param: @param null:
     * @return:
     * @Date 2021/4/15 15:07
     * @throws
     */
    //@ApiOperation用于描述接口方法，作用于方法上
    @ApiOperation(value = "自己测试用",notes = "<span style='color:red;'>自己测试用</span>")
    //@ApiResponses用于描述响应状态信息
    @ApiResponses({
            @ApiResponse(code = 20000,message = "新增成功"),
            @ApiResponse(code=20001,message = "新增失败"),
            @ApiResponse(code=30001,message = "输入参数有误")
    })
    //@ApiImplicitParams用于描述接口参数
    @ApiImplicitParams({
            //dataType:参数类型
            //paramType:参数由哪里获取     path->从路径中获取，query->?传参，body->ajax请求
            @ApiImplicitParam(name = "setoreId",value = "门店ID",dataType = "Integer",paramType = "query",example = "满减"),
    })
    @GetMapping("appraisetest")
    public StoreServiceDto testTestTest(Integer setoreId){
        StoreServiceDto storeServiceByStoreId =
                feignService.findStoreServiceByStoreId(setoreId);
        return storeServiceByStoreId;
    }
}

